//
// Created by Felix on 24-4-27.
//

#ifndef GAZE_ERRORHANDLER_HPP
#define GAZE_ERRORHANDLER_HPP

#include "oatpp/web/server/handler/ErrorHandler.hpp"
#include "oatpp/web/protocol/http/outgoing/ResponseFactory.hpp"

#include "dto/DTOs.hpp"

class ErrorHandler : public oatpp::web::server::handler::ErrorHandler {
private:
    typedef oatpp::web::protocol::http::outgoing::Response OutgoingResponse;
    typedef oatpp::web::protocol::http::Status Status;
    typedef oatpp::web::protocol::http::outgoing::ResponseFactory ResponseFactory;
private:
    std::shared_ptr<oatpp::data::mapping::ObjectMapper> iObjectMapper;
public:
    explicit ErrorHandler(
            const std::shared_ptr<oatpp::data::mapping::ObjectMapper> &objectMapper
    ) : iObjectMapper(objectMapper) {}

    std::shared_ptr<OutgoingResponse>
    handleError(const Status &status, const oatpp::String &message, const Headers &headers) override;

};

#endif //GAZE_ERRORHANDLER_HPP
